#ifndef _OH_CONTAINER_H
#define	_OH_CONTAINER_H
/*******************************************************************************
 ** Name: container.hpp                                                       **
 ** Description: WorldObject-derived container objects                        **
 **                                                                           **
 ** Open Source Initiative (OSI) Approved License                             **
 **                                                                           **
 ** The contents of this file are subject to the terms of the                 **
 ** Common Development and Distribution License, Version 1.0 only             **
 ** (the "License").  You may not use this file except in compliance          **
 ** with the License.                                                         **
 **                                                                           **
 ** You can find a copy of the license in the license.txt within              **
 ** this distribution or at http://www.munixos.net/licensing.                 **
 ** Software distributed under the License is distributed on an "AS IS"       **
 ** basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.           **
 ** See the License for the specific language governing permissions           **
 ** and limitations under the License.                                        **
 **                                                                           **
 ** When distributing Covered Code, include this CDDL header in each          **
 ** file and include the License file at $$HOME/license.txt.                  **
 ** If applicable, add the following below this header, with the indicated    **
 ** fields enclosed by brackets "[]" replaced with your own identifying       **
 ** information: Portions Copyright [yyyy] [name of copyright owner]          **
 **                                                                           **
 **                                                                           **
 ** Copyright (c) 2009-2011  Barry Gian James <gian@gamingods.net>            **
 ** All rights reserved.                                                      **
 ******************************************************************************/
// Portions (c) 2012 Open Design Strategies, LLC.
// Modified $Date$ by $Author$
#define _container_h_ID    "$Id$"

#include <iostream>
#include <vector>
#include "item.hpp"
#include "character.hpp"

#define DEFAULT_DOOR_HP     75
#define DEFAULT_CAPACITY	75

// Container flags
#define CONTAINER_IS_OPEN	0x01
#define CONTAINER_LOCKED	0x02
#define CONTAINER_PICKABLE	0x04

//! @class Container
//! @brief The base container class.
#pragma db object table("containers")
class Container : public Item
{
public:
	SMART_PTR_DECL(Container);

	Container() : Item() { }
    Container(const std::string &n, const std::string & t);	// should not be allowed to be called.
    Container(const Container& orig);
    virtual ~Container();

    virtual std::string    TypeToStr() { return "Container"; }

    ushort &		OpenDC() { return open_dc_; }
    entity_t &		Key() { return key_; }
    ushort &		Capacity() { return capacity_; }
    bool			Open() { return _flags & CONTAINER_IS_OPEN; }
    bool			Locked() { return _flags & CONTAINER_LOCKED; }
    bool			Pickable() { return _flags & CONTAINER_PICKABLE; }

    void     AddItem(entity_t o) { contains_.push_back(o); }
    inline void     RemoveItem(entity_t);
    Item::pointer & GetItem(entity_t);

private:
    std::vector<entity_t> contains_;
//   std::vector<Item::pointer> contains;
    ushort             	open_dc_;
    entity_t			key_;	// if key, this is the id
    ushort				capacity_;
};


///////////////////////////////[ Region
// Region flags
#define REGION_PVP_ENA		0x01

//! @class Region
//! @brief Rooms can be grouped with like rooms called regions
// Should regions have portals to other regions?
#pragma db object table("regions")
class Region
{
public:
	Region() { _id = _flags = 0; }
	Region(const Region &);

	// Getters
	const entity_t		ID() const { return _id; }
	const std::string &	Name() const { return _name; }
	const std::string &	Desc() const { return _desc; }
	const unsigned int Flags()const  { return _flags; }

	// Setters
	void	Name(const std::string & n) { _name = n; }
	void	Desc(const std::string & d) { _desc = d; }



private:
	friend class odb::access;
	#pragma db id auto
	entity_t		_id;
	std::string		_name;
	std::string		_desc;
	unsigned int	_flags;
};

// Flags
#define FLAG_REQUIRES_TRAINING	0x01

enum class VehicleTypeEnum
{
	Car, Truck, Jeep, Tank, APC, Helicopter, Airplane,
	Jet, Boat, Motorcycle, Submarine, Hovercraft
};
enum class VehicleClassEnum { Land, Air, Water };
enum class VehicleLocomotionEnum { Treaded, Wheeled, Rotor, Jet, Propeller, Legged };
#pragma db object table("vehicles")
class Vehicle : public Container
{
public:
	Vehicle() : Container() { }
	Vehicle(const std::string & n, const std::string & t);
	Vehicle(const Vehicle &);

	const VehicleClassEnum 	VehicleClass() 	const { return _vclass; }
	const VehicleTypeEnum		VehicleType() 	const { return _vtype; }
	const VehicleLocomotionEnum VehicleLocomotion() const { return _locomotion; }
	const int 				PilotDC() 	const { return _pilot_dc; }
	const ushort 			Speed() 	const { return _speed; }
	const ushort			MaxSpeed() const { return _speed_max; }
	const ushort			MaxPassengers() const { return _passengers_max_; }

	void	VehicleClass(const VehicleClassEnum v) { _vclass = v; }
	void	VehicleType(const VehicleTypeEnum t) { _vtype = t; }
	void	VehicleLocomotion(const VehicleLocomotionEnum l) { _locomotion = l; }
	void	PilotDC(const int d) { _pilot_dc = d; }
	void	Speed(const ushort s) { _speed = s; }
	void	MaxSpeed(const ushort s) { _speed_max = s; }
	void	MaxPassengers(const ushort p) { _passengers_max_ = p; }

	int					RequiresTraining() { return(_flags & FLAG_REQUIRES_TRAINING); }
	void				RequiresTraining(bool t) { if (t) BMSET(_flags,FLAG_REQUIRES_TRAINING); else BMCLR(_flags,FLAG_REQUIRES_TRAINING); }

protected:
	friend class odb::access;

#pragma db type ("VARCHAR(16)")
	VehicleClassEnum	_vclass;
#pragma db type ("VARCHAR(16)")
	VehicleTypeEnum		_vtype;
#pragma db type ("VARCHAR(16)")
	VehicleLocomotionEnum _locomotion;
	int					_pilot_dc;	// difficulty to pilot/drive/steer
	ushort				_speed, _speed_max;
	ushort				_passengers_max_;
	std::vector<std::string>	_traits;
};


#endif	/* _OH_CONTAINER_H */

